Chart for WPF and Silverlight > Chart Features > Saving and Exporting C1Chart > Exporting Chart Image |
You can export a chart image by using the RenderTargetBitmap like in the following code:
Visual Basic |
Copy Code
|
---|---|
Dim bm As New RenderTargetBitmap(CInt(c1Chart1.ActualWidth), CInt(c1Chart1.ActualHeight), 96, 96, PixelFormats.[Default])
bm.Render(c1Chart1)
Dim enc As New PngBitmapEncoder()
enc.Frames.Add(BitmapFrame.Create(bm))
Dim fs As New FileStream("chart.png", FileMode.Create)
enc.Save(fs)
|
C# |
Copy Code
|
---|---|
RenderTargetBitmap bm = new RenderTargetBitmap( (int)c1Chart1.ActualWidth,(int)c1Chart1.ActualHeight, 96, 96, PixelFormats.Default); bm.Render(c1Chart1); PngBitmapEncoder enc = new PngBitmapEncoder(); enc.Frames.Add(BitmapFrame.Create(bm)); FileStream fs = new FileStream("chart.png", FileMode.Create); enc.Save(fs); |